package com.team.arms.yuding.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.team.arms.yuding.domain.DoubleQualified;
import com.team.arms.yuding.domain.dto.ReservedDto;
import com.team.arms.yuding.domain.vo.ReservedVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author yjh
 * @create 2022-05-07-20:52
 * @description:
 */
public interface ReservedMapper extends BaseMapper<ReservedVo> {

    List<ReservedVo> selectAll();

//    @Select(" select double_qualified_id,name,sex,year,batch,login_number,age,nation,household_type,cultureral_program,\n" +
//            "        registration_time,is_order_soldiers,join_approve_id,join_inform_id\n" +
//            "        from y_double_qualified as d,y_before_military as b\n" +
//            "        where d.before_military_id=b.before_military_id and name like \"%${name}%\"\n" +
//            "        and d.is_order_soldiers = \"是\"")
//    List<ReservedVo> selectByName(@Param("name") String name);
//
//    @Select(" select double_qualified_id,name,sex,year,batch,login_number,age,nation,household_type,cultureral_program,\n" +
//            "        registration_time,is_order_soldiers,join_approve_id,join_inform_id\n" +
//            "        from y_double_qualified as d,y_before_military as b\n" +
//            "        where d.before_military_id=b.before_military_id and sex = #{sex}\n" +
//            "        and d.is_order_soldiers = \"是\"")
//    List<ReservedVo> selectBySex(@Param("sex") String sex);
//
//    @Select(" select double_qualified_id,name,sex,year,batch,login_number,age,nation,household_type,cultureral_program,\n" +
//            "        registration_time,is_order_soldiers,join_approve_id,join_inform_id\n" +
//            "        from y_double_qualified as d,y_before_military as b\n" +
//            "        where d.before_military_id=b.before_military_id and  year like \"%${year}%\"\n\n" +
//            "        and d.is_order_soldiers = \"是\"")
//    List<ReservedVo> selectByYear(@Param("year") String year);
//
//    @Select(" select double_qualified_id,name,sex,year,batch,login_number,age,nation,household_type,cultureral_program,\n" +
//            "        registration_time,is_order_soldiers,join_approve_id,join_inform_id\n" +
//            "        from y_double_qualified as d,y_before_military as b\n" +
//            "        where d.before_military_id=b.before_military_id and batch = #{batch}\n" +
//            "        and d.is_order_soldiers = \"是\"")
//    List<ReservedVo> selectByBatch(@Param("batch") String batch);
//
//    @Select(" select double_qualified_id,name,sex,year,batch,login_number,age,nation,household_type,cultureral_program,\n" +
//            "        registration_time,is_order_soldiers,join_approve_id,join_inform_id\n" +
//            "        from y_double_qualified as d,y_before_military as b\n" +
//            "        where d.before_military_id=b.before_military_id and  login_number like \"%${loginNumber}%\"\n\n" +
//            "        and d.is_order_soldiers = \"是\"")
//    List<ReservedVo> selectByLoginNumber(@Param("loginNumber") String loginNumber);
//
//    @Select(" select double_qualified_id,name,sex,year,batch,login_number,age,nation,household_type,cultureral_program,\n" +
//            "        registration_time,is_order_soldiers,join_approve_id,join_inform_id\n" +
//            "        from y_double_qualified as d,y_before_military as b\n" +
//            "        where d.before_military_id=b.before_military_id and age = #{age}\n" +
//            "        and d.is_order_soldiers = \"是\"")
//    List<ReservedVo> selectByAge(@Param("age") String age);
//
//    @Select(" select double_qualified_id,name,sex,year,batch,login_number,age,nation,household_type,cultureral_program,\n" +
//            "        registration_time,is_order_soldiers,join_approve_id,join_inform_id\n" +
//            "        from y_double_qualified as d,y_before_military as b\n" +
//            "        where d.before_military_id=b.before_military_id and nation = #{nation}\n" +
//            "        and d.is_order_soldiers = \"是\"")
//    List<ReservedVo> selectByNation(@Param("nation") String nation);
//
//    @Select(" select double_qualified_id,name,sex,year,batch,login_number,age,nation,household_type,cultureral_program,\n" +
//            "        registration_time,is_order_soldiers,join_approve_id,join_inform_id\n" +
//            "        from y_double_qualified as d,y_before_military as b\n" +
//            "        where d.before_military_id=b.before_military_id and household_type = #{householdType}\n" +
//            "        and d.is_order_soldiers = \"是\"")
//    List<ReservedVo> selectByHouseholdType(@Param("household_type") String householdType);
//
//    @Select(" select double_qualified_id,name,sex,year,batch,login_number,age,nation,household_type,cultureral_program,\n" +
//            "        registration_time,is_order_soldiers,join_approve_id,join_inform_id\n" +
//            "        from y_double_qualified as d,y_before_military as b\n" +
//            "        where d.before_military_id=b.before_military_id and cultureral_program = #{cultureralProgram}\n" +
//            "        and d.is_order_soldiers = \"是\"")
//    List<ReservedVo> selectByCultureralProgram(@Param("cultureral_program") String cultureralProgram);
//
//    @Select(" select double_qualified_id,name,sex,year,batch,login_number,age,nation,household_type,cultureral_program,\n" +
//            "        registration_time,is_order_soldiers,join_approve_id,join_inform_id\n" +
//            "        from y_double_qualified as d,y_before_military as b\n" +
//            "        where d.before_military_id=b.before_military_id and join_approve_id like \"%${joinApproveId}%\"\n" +
//            "        and d.is_order_soldiers = \"是\"")
//    List<ReservedVo> selectByJoinApproveId(@Param("join_approve_id") String joinApproveId);
//
//    @Select(" select double_qualified_id,name,sex,year,batch,login_number,age,nation,household_type,cultureral_program,\n" +
//            "        registration_time,is_order_soldiers,join_approve_id,join_inform_id\n" +
//            "        from y_double_qualified as d,y_before_military as b\n" +
//            "        where d.before_military_id=b.before_military_id and join_inform_id like \"%${joinInformId}%\"\n\n" +
//            "        and d.is_order_soldiers = \"是\"")
//    List<ReservedVo> selectByJoinInformId(@Param("join_inform_id") String joinInformId);
//
//    @Select(" select double_qualified_id,name,sex,year,batch,login_number,age,nation,household_type,cultureral_program,\n" +
//            "        registration_time,is_order_soldiers,join_approve_id,join_inform_id\n" +
//            "        from y_double_qualified as d,y_before_military as b\n" +
//            "        where d.before_military_id=b.before_military_id and registration_time like \"%${registrationTime}%\"\n\n" +
//            "        and d.is_order_soldiers = \"是\"")
//    List<ReservedVo> selectByRegistrationTime(@Param("registration_time") String registrationTime);

    @Select("select double_qualified_id,name,sex,year,batch,login_number,age,nation,household_type,cultureral_program,\n" +
            " registration_time,is_order_soldiers,join_approve_id,join_inform_id\n" +
            " from y_double_qualified as d,y_before_military as b\n" +
            " where d.before_military_id=b.before_military_id\n" +
            " and d.is_order_soldiers = \"是\"\n" +
            " and ${fields} like CONCAT('%',#{content},'%')")
    List<ReservedVo> selectByFiled(@Param("fields") String fields, @Param("content") String content);

    int updateIsOrderSoldiersByDoubleQualifiedId(@Param("isOrderSoldiers") String isOrderSoldiers, @Param("doubleQualifiedId") String doubleQualifiedId);

    @Select("<script>select double_qualified_id,name,sex,year,batch,login_number,age,nation,household_type,cultureral_program,\n" +
            " registration_time,is_order_soldiers,join_approve_id,join_inform_id\n" +
            " from y_double_qualified AS d,y_before_military as b\n" +
            " where\n" +
            " d.before_military_id=b.before_military_id and d.is_order_soldiers = \"是\"\n" +
            " <if test=\"name != null and name != ''\">\n" +
            "     and name like CONCAT('%',#{name},'%')\n" +
            " </if>\n" +
            " <if test=\"sex != null and sex != ''\">\n" +
            "     and sex = #{sex}\n" +
            " </if>\n" +
            " <if test=\"year != null and year != ''\">\n" +
            "     and year like CONCAT('%',#{year},'%')\n" +
            " </if>\n" +
            " <if test=\"batch != null and batch != ''\">\n" +
            "     and batch = #{batch}\n" +
            " </if>\n" +
            " <if test=\"loginNumber != null and loginNumber != ''\">\n" +
            "     and login_number  like CONCAT('%',#{loginNumber},'%')\n" +
            " </if>\n" +
            " <if test=\"age != null and age != ''\">\n" +
            "     and age = #{age}\n" +
            " </if>\n" +
            " <if test=\"nation != null and nation != ''\">\n" +
            "     and nation = #{nation}\n" +
            " </if>\n" +
            " <if test=\"householdType != null and householdType != ''\">\n" +
            "     and househol_type = #{householdType}\n" +
            " </if>\n" +
            " <if test=\"cultureralProgram != null and cultureralProgram != ''\">\n" +
            "     and cultureral_program = #{cultureralProgram}\n" +
            " </if>\n" +
            " <if test=\"joinApproveId != null and joinApproveId != ''\">\n" +
            "     and join_approve_id like CONCAT('%',#{joinApproveId},'%')\n" +
            " </if>\n" +
            " <if test=\"joinInformId != null and joinInformId != ''\">\n" +
            "     and join_inform_id like CONCAT('%',#{joinInformId},'%')\n" +
            " </if>\n" +
            " <if test=\"registrationTime != null and registrationTime != ''\">\n" +
            "     and registration_time like CONCAT('%',#{registrationTime},'%')\n" +
            " </if></script>")
    List<ReservedVo> selectReserved(ReservedDto reservedDto);

    int insertAll(DoubleQualified doubleQualified);
}
